package com.collaborativelearning;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.TextView;

public class StudentHomePage extends Activity {

	Button logout;
	Button grades;
	Button books;
	Button notes;
	Button hw;
	Button schdule;
	CalendarView calender;
	TextView a1stNotification;
	TextView a2ndNotification;
	boolean seen1 = false;
	boolean seen2 = false;
	boolean done1 = false;
	boolean done2 = false;
	int seen1Text = 0;
	int seen2Text = 0;
	int done1Text = 0;
	int done2Text = 0;

	@Override
	public void onCreate(Bundle savedInstanceState) {

		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.student_home_page);

		a1stNotification = (TextView) findViewById(R.id.a1stNotification);
		a1stNotification.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				if (seen1) {
					seen1Text = R.string.notSeen;
				} else {
					seen1Text = R.string.seen;
				}
				if (done1) {
					done1Text = R.string.notDone;
				} else {
					done1Text = R.string.done;
				}

				new AlertDialog.Builder(StudentHomePage.this)
						.setTitle(a1stNotification.getText())
						.setPositiveButton(done1Text,
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface arg0,
											int arg1) {

										if (done1) {
											a1stNotification.setPaintFlags(a1stNotification
													.getPaintFlags()
													& (~Paint.STRIKE_THRU_TEXT_FLAG));

											done1 = false;
										} else {
											a1stNotification
													.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG
															| Paint.ANTI_ALIAS_FLAG);
											done1 = true;
										}

									}
								})
						.setNegativeButton(seen1Text,
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface arg0,
											int arg1) {

										if (seen1) {
											a1stNotification
													.setTypeface(Typeface.DEFAULT_BOLD);
											a1stNotification.setTextSize(15);
											seen1 = false;
										} else {
											a1stNotification
													.setTypeface(Typeface.DEFAULT);
											a1stNotification.setTextSize(13);
											seen1 = true;
										}

									}
								}).show();

			}
		});

		a2ndNotification = (TextView) findViewById(R.id.a2ndNotification);
		a2ndNotification.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				if (seen2) {
					seen2Text = R.string.notSeen;
				} else {
					seen2Text = R.string.seen;
				}
				if (done2) {
					done2Text = R.string.notDone;
				} else {
					done2Text = R.string.done;
				}

				new AlertDialog.Builder(StudentHomePage.this)
						.setTitle(a2ndNotification.getText())
						.setPositiveButton(done2Text,
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface arg0,
											int arg1) {

										if (done2) {
											a2ndNotification.setPaintFlags(a2ndNotification
													.getPaintFlags()
													& (~Paint.STRIKE_THRU_TEXT_FLAG));

											done2 = false;
										} else {
											a2ndNotification
													.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG
															| Paint.ANTI_ALIAS_FLAG);
											done2 = true;
										}

									}
								})
						.setNegativeButton(seen2Text,
								new DialogInterface.OnClickListener() {
									public void onClick(DialogInterface arg0,
											int arg1) {

										if (seen2) {
											a2ndNotification
													.setTypeface(Typeface.DEFAULT_BOLD);
											a2ndNotification.setTextSize(15);
											seen2 = false;
										} else {
											a2ndNotification
													.setTypeface(Typeface.DEFAULT);
											a2ndNotification.setTextSize(13);
											seen2 = true;
										}

									}
								}).show();

			}
		});

		logout = (Button) findViewById(R.id.logout);
		logout.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				startActivity(new Intent(getApplicationContext(),
						LoginActivity.class));
			}
		});

		grades = (Button) findViewById(R.id.grades);
		grades.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				// startActivity(new Intent());
			}
		});

		books = (Button) findViewById(R.id.books);
		books.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				startActivity(new Intent(getApplicationContext(),
						UnitListActivity.class));
			}
		});

		notes = (Button) findViewById(R.id.notes);
		notes.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				// startActivity(new Intent());
			}
		});

		hw = (Button) findViewById(R.id.hw);
		hw.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				// startActivity(new Intent());
			}
		});

		schdule = (Button) findViewById(R.id.schdule);
		schdule.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {

				// startActivity(new Intent());
			}
		});
	}
}
